function PopupBoxH() {
  this._background = null;
  this._container = null;
}

PopupBoxH.prototype._reset = function(pos) {
  var _self = this;
  this._close();
  
  this._background = document.createElement('div');
  this._background.cellPadding = 0;
  this._background.cellSpacing = 0;
  this._background.className = 'popupBlack';
  this._background.style.width = document.body.offsetWidth + 'px';
  this._background.style.height = document.body.offsetHeight + 'px';
  document.body.appendChild(this._background);
  
  if (this._pop) {
    this._background.onclick = function() { _self._close(); };
  }
  
  var div1 = document.createElement('div');
  div1.className="round1";
  var div2 = document.createElement('div');
  div2.className="round2";
  var div4 = document.createElement('div');
  div4.className="round4";
  var div11 = document.createElement('div');
  div11.className="round1";
  var div22 = document.createElement('div');
  div22.className="round2";
  var div44 = document.createElement('div');
  div44.className="round4";
  
  var toptable = document.createElement('table');
  toptable.cellPadding = 0;
  toptable.cellSpacing = 0;
  var ttr = toptable.insertRow(-1);
  td = ttr.insertCell(-1);
  td.style.padding = '0 4px';
  td.appendChild(div44);
  ttr = toptable.insertRow(-1);
  td = ttr.insertCell(-1);
  td.style.padding = '0 2px';
  td.appendChild(div22);
  ttr = toptable.insertRow(-1);
  td = ttr.insertCell(-1);
  td.style.padding = '0 1px';
  td.appendChild(div11);
  
  
  var bottable = document.createElement('table');
  bottable.cellPadding = 0;
  bottable.cellSpacing = 0;
  var ttr = bottable.insertRow(-1);
  td = ttr.insertCell(-1);
  td.style.padding = '0 1px';
  td.appendChild(div1);
  ttr = bottable.insertRow(-1);
  td = ttr.insertCell(-1);
  td.style.padding = '0 2px';
  td.appendChild(div2);
  ttr = bottable.insertRow(-1);
  td = ttr.insertCell(-1);
  td.style.padding = '0 4px';
  td.appendChild(div4);
  
  this._container = document.createElement('table');
  this._container.cellPadding = 0;
  this._container.cellSpacing = 0;
  this._container.className = (this._pop) ? 'popupSimpleBase1' : 'popupBase2';
  this._container.style.top = ((this._position[1] - 60) > 0) ? (this._position[1] - 60) + 'px' : '0px';
  this._container.style.left = ((this._position[0] + 200) > window.screen.width) ? (window.screen.width - 200) + 'px' : this._position[0] + 'px';
  var itable = document.createElement('table');
  itable.cellPadding = 0;
  itable.cellSpacing = 0;
  itr = itable.insertRow(-1);
  td = itr.insertCell(-1);
  main = document.createElement('div');
  td.appendChild(main);
  
  tr = this._container.insertRow(-1);
  td = itr.insertCell(-1);
  this._container.appendChild(toptable);
  
  tr = this._container.insertRow(-1);
  td = itr.insertCell(-1);
  this._container.appendChild(itable);
  
  tr = this._container.insertRow(-1);
  td = itr.insertCell(-1);
  this._container.appendChild(bottable);
  
  this._background.appendChild(this._container);
  
  var posX = this._position[0];
  var posY = ((this._position[1] - 100) > 0) ? (this._position[1] - 100) : 0;
  window.scrollTo(posX, posY);
  
  
};

PopupBoxH.prototype._open = function(container, options) {
  var table, tr, td, _self = this;

  this._position = (options && options.pos) ? options.pos : [((document.body.offsetWidth / 2) - 50), ((document.body.offsetHeight / 2) - 50)];
  
  this._pop = (options && options.pop) ? options.pop : null;
  this._reset();

  table = document.createElement('table');
  table.cellPadding = 0;
  table.cellSpacing = 0;
  tr = table.insertRow(-1);
  td = tr.insertCell(-1);
  td.appendChild(container);
  main.appendChild(table);
};

PopupBoxH.prototype._close = function() {
  if (this._background) {
    document.body.removeChild(this._background);
    this._background = null;
    this._container = null;
  }
};


